package com.ljf.authority.infra.assembler;

import com.ljf.authority.vo.*;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 菜单列表定义  类型转换类
 * 
 * @author LJF
 * @since 2024-10-17
 */
@Mapper
public interface AuthorityBaseMenuTabulationAssembler {

    AuthorityBaseMenuTabulationAssembler INSTANCE = Mappers.getMapper(AuthorityBaseMenuTabulationAssembler.class);

    @Mapping(target = "index", source = "model.sort")
    @Mapping(target = "children", ignore = true)
    AuthorityBaseMenuTabulationMainMenuVO toMainMenuVO(AuthorityBaseMenuTabulationIndexVO model, String picCode);

    List<AuthorityBaseMenuTabulationMenuClassificationVO> toMenuClassificationVO(List<AuthorityBaseMenuTabulationIndexVO> modelList);

    AuthorityBaseMenuTabulationMenuPageVO toMenuPageVO(AuthorityBaseMenuTabulationIndexVO model, String componentUrl);

    List<AuthorityBaseMenuTabulationIndexVO> toIndexVO(List<AuthorityBaseMenuTabulationVO> modelList);

    List<AuthorityBaseMenuTabulationButtonVO> toButtonVO(List<AuthorityBaseMenuTabulationVO> modelList);

    @BeanMapping(ignoreByDefault = true)
    @Mapping(target = "clickFunction", source = "detail.clickFunction")
    @Mapping(target = "width", source = "detail.width")
    void toFillButtonInfo(@MappingTarget AuthorityBaseMenuTabulationButtonVO model, AuthorityBaseButtonDetailVO detail);

}
